﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Emerson.Storage.Entities;
using Emerson.Storage.Agent.Core;

namespace Emerson.Storage.Service
{
    /// <summary>
    /// EntityInfo is used in communication between agent and service,(Agent is running in .Net framework 2.0, so it cannot support EF objects
    /// </summary>
    static class EntityHelper
    {
        public static Workstation ConvertToWorkstation(this WorkstationInfo wi)
        {
            Workstation wk = new Workstation();
            wk.Name = wi.Name;
            wk.OSVersion = wi.OSVersion;
            wk.IPAddress = wi.IPAddress;
            return wk;
        }

        public static Battery ConvertToBattery(this BatteryInfo bi)
        {
            Battery bat = new Battery();
            bat.BatteryType = bi.BatteryType;
            bat.PercentRemaining = bi.PercentRemaining;
            bat.IsConnected = bi.IsConnected;
            bat.LogTime = bi.LastConnectedTime;
            bat.Temperature = bi.Temperature;

            return bat;
        }

        public static void UpdateWorkstationData(this Workstation wk, WorkstationInfo wi)
        {
            wk.Name = wi.Name;
            wk.OSVersion = wi.OSVersion;
            wk.Note = "";
        }

        public static void UpdateBatteryData(this  Battery bat, BatteryInfo bi)
        {
            bat.PercentRemaining = bi.PercentRemaining;
            bat.IsConnected = bi.IsConnected;
            bat.LogTime = bi.LastConnectedTime;
            bat.Temperature = bi.Temperature;
        }
    }
}
